package com.home.qh.webapp.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.home.qh.model.Paying;
import com.home.qh.service.PayingManager;

@Controller
public class PayingController {
	private transient final Log log = LogFactory.getLog(PayingController.class);
	private PayingManager payingManager;
	
    @Autowired
    private ApplicationContext context;
    
    @Autowired
    public void setPayingManager(PayingManager payingManager) {
        this.payingManager = payingManager;
    }
	
    @RequestMapping(value = "/admin/payingList.*", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView listCountries(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        if (log.isDebugEnabled()) {
            log.debug("entering 'handleRequest' method...");
        }
        
        Paying payingSearch = new Paying();
        String paramValue = request.getParameter("name");
        if (paramValue != null && !"".equalsIgnoreCase(paramValue.trim()) && !"null".equalsIgnoreCase(paramValue))
        {
        	payingSearch.setCode(paramValue);
        	payingSearch.setName(paramValue);
        }
        
        ModelAndView view = new ModelAndView("admin/payingList");
        view.addObject("payingSearch", payingSearch);
        
        view.addObject("payingList", payingManager.getPayingByPaying(payingSearch, null, false, -1, -1));
        return view;

    }

}
